﻿#include <QFile>
#include "CRobMovePointDlg.h"
#include "CHeader.h"

CRobMovePointDlg::CRobMovePointDlg(CPolPoint* pPoint, QWidget *parent)
	: m_pPoint(pPoint),QDialog(parent)
{
	ui.setupUi(this);
	setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
	setStyleSheetFile();
	initConnect();
}

CRobMovePointDlg::~CRobMovePointDlg()
{}

void CRobMovePointDlg::setStyleSheetFile()
{
	setWindowTitle(A2T("移动巡检点"));
	QString sQssPath = ":/qss/styleSheet.css";
	QFile qss(sQssPath);
	qss.open(QFile::ReadOnly);
	this->setStyleSheet(qss.readAll());
}

void CRobMovePointDlg::initConnect()
{
	connect(ui.pushButtonOk, &QPushButton::clicked, this, &CRobMovePointDlg::slotPushButtonOk);
	connect(ui.pushButtonCancle, &QPushButton::clicked, this, &CRobMovePointDlg::slotPushButtonCancle);
}

void CRobMovePointDlg::slotPushButtonOk()
{
	if (ui.lineEditMoveDis->text() == "")
	{
		messageBox(0, A2T("请填写完整后在进行操作"));
	}

	m_pPoint->m_dPointLocation += ui.lineEditMoveDis->text().toDouble();
	if (m_pPoint->m_nPointStatus == 0)//之前未变
	{
		m_pPoint->m_nPointStatus = 2;
	}
	else if (m_pPoint->m_nPointStatus == 1)//之前新增
	{
		m_pPoint->m_nPointStatus = 1;
	}
	else if (m_pPoint->m_nPointStatus == 2)//之前是修改过的
	{
		m_pPoint->m_nPointStatus = 2;
	}
	messageBox(0, A2T("移动成功"));
	this->close();
}

void CRobMovePointDlg::slotPushButtonCancle()
{
	this->close();
}
